package com.zx.controller;

import com.zx.entity.Achievements;
import com.zx.service.AchievementInte;
import org.apache.taglibs.standard.lang.jstl.test.beans.PublicBean1;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 程仟磊
 * @date 2021/7/27
 */
@Controller
public class Achievementc {
    @Resource
    private AchievementInte achievementInte;
    //根据用户查询项目用于申报成果
    @ResponseBody
    @RequestMapping("/findProjectByName")
    public List findProjectByName(HttpSession httpSession){
        String user = String.valueOf(httpSession.getAttribute("user"));
        return achievementInte.findProjectByName(user);
    }
    //成果申报
    @RequestMapping("/addAchievement")
    public void  addAchievement(Achievements achievements){
        achievementInte.addAchievement(achievements);

    }
    //成果认定
    @RequestMapping("/updateAchievement")
    public void updateAchievement(String aid,String astate){
        achievementInte.updateAchievement(aid,astate);
    }
    //查询成果
    @ResponseBody
    @RequestMapping("/findAchieventById")
    public Object findAchieventById(String pid){
      return achievementInte.findAchieventById(pid);
    }
    @ResponseBody
    @RequestMapping("/findProjectBystate")
    public List findProjectBystate(HttpSession httpSession,String astate){
        String user = String.valueOf(httpSession.getAttribute("user"));
        return achievementInte.findProjectBystate("李四",astate);
    }
    //查询所有成果
    @ResponseBody
    @RequestMapping("/findAllAchievement")
    public List findAllAchievement(){
        return achievementInte.findAllAchievement();
    }
    //查询登陆者能更改的成果
    @ResponseBody
    @RequestMapping("/findMyAchievement")
    public List findMyAchievement(HttpSession session){
        String user = String.valueOf(session.getAttribute("user"));
        return achievementInte.findMyAchievement(user);
    }
    //更改成功
    @RequestMapping("/changeAchievement")
    public void changeAchievement(Achievements achievements){
        achievementInte.changeAchievement(achievements);
    }

}
